<template>
    <div class="page-100 repair-order-part">
        <yd-navbar height="0.9rem"
                   title="维修单"
                   fontsize=".3rem"
                   class="repair-navbar-part">
            <img slot="right" v-if="popWinList.length>0"
                 class="operation-logo-part"
                 src="../../assets/home_dark_more_icon.png" @click="showOperationHandler"/>
        </yd-navbar>
        <PopWindowDialog style="position: fixed;top:0;right: 0;margin-top: 0.9rem"
                         :isShowPopDialog="isShowPopDialog"
                         v-on:pop-handler="popHandlerClick"
                         :popDatas="popWinList"/>
        <div style="padding-top: 1rem">
            <div class="repair-main-part bottom-line-part" v-for="(item,index) in repairData">
                <!--文本组件-->
                <RevealMsgComponent
                        class="reveal-msg-component-part"
                        :revealMsgTitle="item.title"
                        :revealContent="item.content"
                        :contentType="item.type"
                        :clickType="item.clickType"
                        :isEditState="isEnableEdit"
                        v-on:deviceCodeChange="deviceCodeHandler"
                        v-on:click.native="revealHandleClick(item.clickType)">

                    <!--插槽：图片组件-->
                    <!--&& images.length !== 0-->
                    <ImageShowComponent
                            v-if="item.showType === 'image' "
                            class="image-component-part"
                            slot="slot"
                            :imageObjList="item.images"
                            :qiNiuUrl="qn_domain"/>

                    <!--插槽：分割块标题-->
                    <div v-else-if="item.showType === 'content'"
                         slot="slot"
                         class="content-main-part">
                        <span class="title-part">在维修完成后填写</span>
                    </div>

                    <!--插槽：分割线-->
                    <div v-else-if="item.showType === 'divide'"
                         slot="slot"
                         class="divide-part"></div>

                    <!--插槽：箭头Logo-->
                    <img v-if="item.showRightTpye === 'arrow'"
                          slot="slot-right-show"
                          src="../../assets/icon-tubiao-.png"
                          class="scan-logo-part">

                    <!--插槽：扫码Logo-->
                    <img v-else-if="item.showRightTpye === 'scan'"
                          slot="slot-right-show"
                          v-on:click="scanHandleClick(item.showRightTpye)"
                          src="../../assets/icon-saoyisao.png"
                          class="scan-logo-part">

                </RevealMsgComponent>
            </div>
            <div style="height: 1.4rem"></div>
        </div>

        <!--紧急程度ActionSheet-->
        <yd-actionsheet :items="urgentItems" v-model="isUrgentSheet" cancel="取消"></yd-actionsheet>
        <!--故障类型ActionSheet-->
        <yd-actionsheet :items="faultItems" v-model="isFaultSheet" cancel="取消"></yd-actionsheet>

        <div class="repair-order-operation-part buttom-tabbar">
            <!--编辑按钮-->
            <a  href="javascript:;"
                @click="editHandleClick"
                v-show="isShowEdit"
                class="weui-btn weui-btn_primary horizontal-part">编辑</a>
            <!--编辑按钮-->
            <a  href="javascript:;"
                @click="sendHandleClick"
                v-show="isShowSend"
                class="weui-btn weui-btn_primary horizontal-part">发送</a>
            <!--保存按钮-->
            <a  href="javascript:;"
                @click="saveHandleClick"
                v-show="isShowSave"
                class="weui-btn weui-btn_primary horizontal-part">保存</a>
            <!--抄送按钮-->
            <a  href="javascript:;"
                @click="copyHandleClick"
                v-show="isShowCopy"
                class="weui-btn weui-btn_primary horizontal-part">抄送</a>
            <!--归档按钮-->
            <a  href="javascript:;"
                @click="archiveHandleClick"
                v-show="isShowArchive"
                class="weui-btn weui-btn_primary horizontal-part">归档</a>
        </div>
    </div>
</template>

<script>
    import RevealMsgComponent from "@/components/RevealMsgComponent.vue";
    import ImageShowComponent from "@/components/ImageShowComponent.vue";
    import PopWindowDialog from "@/components/PopWindowDialog.vue";
    import util from '../../util.js';
    import {orderContentByUser,showFaultTypeSelect,machineCodeDetails,machineUuidDetails,orderArchive,orderApplyByUser,uploadQiNiuImage,launchApplyUpdateByUser} from "../../pcof/post";
    import {providerObject,instObject,userInfoData,qn_domain,isEditRepairOrder,repairOrderData,repairOrderSavedInstance,openId,repairOrderUUid} from '../../globalVariables';
    export default {
        name: "repairOrder",
        data() {
            return {
                //1、从主界面进入：   录入维修单  isEditState = '0'
                //2、从待办界面进入： 维修单详情  isEditState = '1'  TodoItemBean bean
                //3、从历史界面进入： 历史维修单  isEditState = '0'
                isEditState: '0',
                taskUUid: '',
                userUuid: '',
                repairState: '',
                repairData:  [
                    {clickType: 'repair',title: '报修人',content: '',type: 'entry',showRightTpye: '',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'inst',title: '报修机构',content: '',type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'phone',title: '联系电话',content: '',type: 'text',showRightTpye: 'arrow',showType: 'divide',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'urgent',title: '紧急程度',content: '',type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '10',ccList:[]},
                    {clickType: 'fault',title: '故障类型',content: '',type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'deviceCode',title: '设备编码',content: '',type: 'entry',showRightTpye: 'scan',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'device',title: '报修设备',content: '根据设备编码自动匹配',type: 'text',showRightTpye: '',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'faultDes',title: '故障描述',content: '',type: 'textarea',showRightTpye: '',showType: 'image',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'repairDate',title: '报修日期',content: '',type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'repairTime',title: '报修时间',content: '',type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'copyFor',title: '抄送给',content: '',type: 'textarea',showRightTpye: 'arrow',showType: 'content',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'company',title: '维修单位',content: '',type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'repairPeople',title: '维修人员',content: '',type: 'entry',showRightTpye: '',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'arrivalDate',title: '维修人员到达日期',content: '',type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'arrivalTime',title: '维修人员到达时间',content: '',type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'faultRepairDate',title: '故障修复日期',content: '',type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'faultRepairTime',title: '故障修复时间',content: '',type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    {clickType: 'remark',title: '备注',content: '',type: 'entry',showRightTpye: '',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                ],
                isUrgentSheet: false,
                urgentItems: [
                    {
                        label: '请选择紧急程度',
                        callback: () => {}
                    },
                    {
                        label: '一般',
                        callback: () => {
                            /* 注意： callback: function() {} 和 callback() {}  这样是无法正常使用当前this的 */
                            this.repairData[3].content = '一般';
                            this.repairData[3].emergencyTypeUuid = '10';
                        }
                    },
                    {
                        label: '比较紧急',
                        callback: () => {
                            this.repairData[3].content = '比较紧急';
                            this.repairData[3].emergencyTypeUuid = '20';
                        }
                    },
                    {
                        label: '紧急',
                        callback: () => {
                            /* 注意： callback: function() {} 和 callback() {}  这样是无法正常使用当前this的 */
                            this.repairData[3].content = '紧急';
                            this.repairData[3].emergencyTypeUuid = '30';
                        }
                    },
                    {
                        label: '非常紧急',
                        callback: () => {
                            this.repairData[3].content = '非常紧急';
                            this.repairData[3].emergencyTypeUuid = '40';
                        }
                    }
                ],
                isFaultSheet: false,
                faultItems: [],
                //银行客户机构Uuid
                instUuid: '',
                //报修日期时间
                repairDate: '',
                repairTime: '',
                //故障修复日期时间
                faultRepairDate: '',
                faultRepairTime: '',
                //运维人员到达日期时间
                arrivalDate: '',
                arrivalTime: '',
                //图片Key
                imageStr: '',
                //控制是否显示编辑按钮
                isShowEdit: false,
                //控制是否显示抄送按钮
                isShowCopy: false,
                //控制是否显示归档按钮
                isShowArchive: false,
                //控制是否显示保存按钮
                isShowSave: false,
                //控制是否显示发送按钮
                isShowSend: false,
                idx: 0,
                serverIds: '',
                qn_domain: '',
                isShowPopDialog: false,
                popWinList: [],
                partnerUuid: '',
                isSendRepairState: false,
                isEnableEdit: true,
                isSamePartnerUuid: true,
            }
        },
        components: {
            RevealMsgComponent,
            ImageShowComponent,
            PopWindowDialog,
        },
        created() {
            console.log('created');
            this.isEditState = localStorage.getItem(isEditRepairOrder);
            this.qn_domain = localStorage.getItem(qn_domain);
            console.log(localStorage.getItem(instObject));
            console.log('isEditState');
            console.log(this.isEditState);

            if (JSON.parse(localStorage.getItem(repairOrderSavedInstance)) === null || JSON.parse(localStorage.getItem(repairOrderSavedInstance)) === '') {

            } else {
                this.repairData = JSON.parse(localStorage.getItem(repairOrderSavedInstance));
                console.log(this.repairData);
            }

            //'0': 待办事项入口状态
            if (this.isEditState === '0') {
                this.taskUUid = JSON.parse(localStorage.getItem(repairOrderData)).uuid;
                this.userUuid = JSON.parse(localStorage.getItem(repairOrderData)).userUuid;
                this.repairState = JSON.parse(localStorage.getItem(repairOrderData)).state;
                this.orderContentByUserFunc();
            }
            //'1': 主要应用入口状态
            else if (this.isEditState === '1') {
                this.showFaultTypeSelectFunc();
                this.repairData[0].content =  JSON.parse(localStorage.getItem(userInfoData)).name;
                if (localStorage.getItem(instObject) === null || localStorage.getItem(instObject) === '') {
                    this.instUuid = JSON.parse(localStorage.getItem(userInfoData)).bankUuid;
                    this.partnerUuid = JSON.parse(localStorage.getItem(userInfoData)).partnerUuid;
                    this.repairData[1].content = JSON.parse(localStorage.getItem(userInfoData)).bankName;
                } else {
                    this.instUuid = JSON.parse(localStorage.getItem(instObject)).uuid;
                    this.repairData[1].content = JSON.parse(localStorage.getItem(instObject)).name;
                    this.partnerUuid = JSON.parse(localStorage.getItem(instObject)).partnerUuid;
                }
                this.repairData[2].content = JSON.parse(localStorage.getItem(userInfoData)).mobile;
                this.repairData[3].content = '一般';
                this.repairData[8].content = util.getNowDate().nowYear+'-'+util.getNowDate().nowMonth+'-'+util.getNowDate().nowDay;
            }
            //'2': 维修单编辑状态
            else if (this.isEditState === '2') {
                this.taskUUid = JSON.parse(localStorage.getItem(repairOrderData)).uuid;
                this.userUuid = JSON.parse(localStorage.getItem(repairOrderData)).userUuid;
                this.repairState = JSON.parse(localStorage.getItem(repairOrderData)).state;
            }

            if (localStorage.getItem(instObject) === null || localStorage.getItem(instObject) === '') {
                this.instUuid = JSON.parse(localStorage.getItem(userInfoData)).bankUuid;
                this.partnerUuid = JSON.parse(localStorage.getItem(userInfoData)).partnerUuid;
            } else {
                this.instUuid = JSON.parse(localStorage.getItem(instObject)).uuid;
                this.repairData[1].content = JSON.parse(localStorage.getItem(instObject)).name;
                this.partnerUuid = JSON.parse(localStorage.getItem(instObject)).partnerUuid;
            }

            console.log(localStorage.getItem(providerObject));
            if (localStorage.getItem(providerObject) === null || localStorage.getItem(providerObject) === '') {

            } else {
                this.repairData[11].provider_uuid = JSON.parse(localStorage.getItem(providerObject)).provider_uuid;
                this.repairData[11].content = JSON.parse(localStorage.getItem(providerObject)).name;
            }

            this.initRepairOperation();
        },
        beforeRouteLeave(to,from,next) {
            console.log({
                to,
                from
            });
            if (this.isSendRepairState === true) {
                next();
            } else {
                if (to.path === '/repair_fault_description' || to.path === '/inst_list/repairOrder'
                    || to.path === '/service_provider' || to.path === '/repair_copy_search') {
                    next();
                } else {
                    if (this.isEditState === '0') {
                        next();
                    } else {
                        // const answer = window.confirm('离开后已填写的内容将会丢失');
                        // if (answer) {
                        //     next();
                        // } else {
                        //     next(false)
                        // }
                        weui.confirm('离开后已填写的内容将会丢失', {
                            title: '',
                            buttons: [{
                                label: '离开',
                                type: 'primary',
                                onClick: function () {
                                    console.log('no');
                                    next();
                                }
                            }, {
                                label: '取消',
                                type: 'default',
                                onClick: function () {
                                    console.log('yes');
                                    next(false);

                                }
                            }]
                        });
                    }
                }
            }
        },
        methods: {
            showOperationHandler() {
                this.isShowPopDialog = !this.isShowPopDialog;
            },
            popHandlerClick(payload) {
                console.log(payload.popObject.type);
                if (payload.popObject.type === 'edit') {
                    this.isEditState = '2';
                    this.isEnableEdit = true;
                    var index = -1;
                    localStorage.setItem(isEditRepairOrder,this.isEditState);
                    for(var i=0 ;i<this.popWinList.length;i++) {
                        if (this.popWinList[i].type === 'copy') {
                            index = i;
                        }

                        if (this.popWinList[i].type === 'edit') {
                            this.popWinList[i].type = 'save';
                            this.popWinList[i].text = '保存';
                        }
                    }
                    if (index !== -1) {
                        this.popWinList.splice(index,1);
                    }
                    this.isShowArchive = false;
                    this.isShowPopDialog = false;
                } else if (payload.popObject.type === 'save') {
                    this.popWinList=[...this.popWinList,{id: 0,type: 'copy',text:'抄送给'}];
                    this.isEnableEdit = false;
                    this.isShowArchive = true;
                    this.isShowPopDialog = false;

                    if (this.isSamePartnerUuid === false) {
                        this.$dialog.toast({
                            mes: "不属于本机构的设备,请修改！",
                            timeout: 1500
                        });
                        return
                    }

                    if (this.repairData[7].content === '' && this.repairData[7].images.length <= 0) {
                        this.$dialog.toast({
                            mes: "请输入故障描述！",
                            timeout: 1500
                        });
                        return
                    }

                    this.repairDate = this.repairData[8].content;
                    this.repairTime = this.repairData[9].content;
                    this.arrivalDate = this.repairData[13].content;
                    this.arrivalTime = this.repairData[14].content;
                    this.faultRepairDate = this.repairData[15].content;
                    this.faultRepairTime = this.repairData[16].content;
                    console.log('repairDate');
                    console.log(this.repairDate);   //2018-06-01
                    console.log('repairTime');
                    console.log(this.repairTime);   //03:00
                    console.log('arrivalDate');
                    console.log(this.arrivalDate);  //2018-06-02
                    console.log('arrivalTime');
                    console.log(this.arrivalTime);  //02:00        undefined
                    console.log('faultRepairDate');
                    console.log(this.faultRepairDate); //2018-06-02
                    console.log('faultRepairTime');
                    console.log(this.faultRepairTime); //02:30     undefined

                    if (this.arrivalTime === undefined) {
                        this.arrivalTime = '';
                    }

                    if (this.faultRepairTime === undefined) {
                        this.faultRepairTime = '';
                    }

                    if (this.arrivalDate === '' && (this.arrivalTime !== '' && this.arrivalTime !== undefined)) {
                        this.$dialog.toast({
                            mes: "请输入维修任务到达日期！",
                            timeout: 1500
                        });
                        return
                    }

                    if (this.faultRepairDate === '' && (this.faultRepairTime !== '' && this.faultRepairTime !== undefined)) {
                        this.$dialog.toast({
                            mes: "请输入故障修复日期！",
                            timeout: 1500
                        });
                        return
                    }

                    if (this.repairTime === '') {
                        this.repairTime = '00:00';
                    }

                    // console.log('-----------------------------');
                    // console.log(this.arrivalDate !== '' && (this.arrivalTime === '' || this.arrivalTime === undefined));
                    if (this.arrivalDate !== '' && (this.arrivalTime === '' || this.arrivalTime === undefined)) {
                        this.arrivalTime = '00:00';
                    }

                    // console.log('----------------------------');
                    // console.log(this.faultRepairDate !== '' && (this.faultRepairTime === '' || this.faultRepairTime === undefined));
                    if (this.faultRepairDate !== '' && (this.faultRepairTime === '' || this.faultRepairTime === undefined)) {
                        this.faultRepairTime = '00:00';
                    }
                    //报修
                    var warningDay = this.repairDate + ' ' + this.repairTime;
                    //故障修复
                    var repairDay = this.faultRepairDate + ' ' + this.faultRepairTime;
                    //运维人员到达
                    var maintenanceDay = this.arrivalDate + ' ' + this.arrivalTime;
                    // console.log('warningDay');
                    // console.log(warningDay);
                    // console.log('repairDay');
                    // console.log(repairDay);
                    // console.log('maintenanceDay');
                    // console.log(maintenanceDay);
                    //故障修复时间不得早于维修人员到达时间 (不得小于)
                    if (repairDay !== ' ' && maintenanceDay !== ' ' && !util.compareTime(repairDay,maintenanceDay)) {
                        this.$dialog.toast({
                            mes: "故障修复时间不得早于维修人员到达时间！",
                            timeout: 1500
                        });
                        return
                    }
                    //维修人员到达时间不得早于报修时间 （不得小于）
                    if (maintenanceDay !== ' ' && warningDay !== ' ' && !util.compareTime(maintenanceDay,warningDay)) {
                        this.$dialog.toast({
                            mes: "维修人员到达时间不得早于报修时间！",
                            timeout: 1500
                        });
                        return
                    }

                    this.$dialog.loading.open('发送中...');
                    if (this.repairData[7].images.length > 0) {
                        this.repairOrderWXUploadImgFunc('updateByUser');
                    } else {
                        this.launchApplyUpdateByUserFunc();
                    }
                } else if (payload.popObject.type === 'copy') {

                    this.isShowPopDialog = false;

                    //离开当前页面之前先保存起来
                    localStorage.setItem(repairOrderSavedInstance,JSON.stringify(this.repairData));
                    localStorage.setItem(isEditRepairOrder,this.isEditState);
                    this.$router.push({name: 'repairCopySearch',params:{taskUUid: this.taskUUid}});
                }
            },
            async showFaultTypeSelectFunc() {
                var response = await showFaultTypeSelect(JSON.parse(localStorage.getItem(userInfoData)).mobile);
                if (response.data.code === 200) {
                    var title = [{label: '请选择故障类型', callback: () => {}},];
                    var faultList = response.data.data;
                    var list = [];
                    var bean;
                    this.repairData[4].content = faultList[3].type_name;
                    this.repairData[4].faultTypeUuid = faultList[3].uuid;
                    for (var i = 0;i<faultList.length;i++) {
                        bean = {
                            label: faultList[i].type_name,
                            callback: (target) => {
                                this.repairData[4].content = target.label;
                                for (var j = 0;j<faultList.length;j++) {
                                    if (faultList[j].type_name === target.label) {
                                        this.repairData[4].faultTypeUuid = faultList[j].uuid;
                                    }
                                }
                            }
                        };
                        list.push(bean);
                    }
                    this.faultItems = [...title,...list];
                } else {
                    this.$dialog.toast({
                        mes: response.data.msg,
                        timeout: 1500
                    });
                }
            },
            //获取录入维修单详情
            async orderContentByUserFunc() {
                var response = await orderContentByUser(
                    JSON.parse(localStorage.getItem(userInfoData)).mobile,
                    this.taskUUid
                );
                if (response.data.code === 200) {
                    var orderData = response.data.data;
                    var list = [];
                    if (orderData.image === "" || orderData.image === null) {
                    } else {
                        var imgList = orderData.image.split(",");
                        for (var i = 0;i<imgList.length;i++) {
                            var imageObj = new Object();
                            imageObj.imageType = 'QiNiu';
                            imageObj.imageUrl = imgList[i];
                            list.push(imageObj);
                        }
                        // this.repairData[7].images = list;
                    }
                    var repairDate = '';
                    var repairTime = '';
                    var arrivalDate = '';
                    var arrivalTime = '';
                    var faultRepairDate = '';
                    var faultRepairTime = '';
                    if (orderData.created !== null || orderData.created !== '') {
                        var createdList = orderData.created.split(" ");
                        repairDate = createdList[0];
                        repairTime = createdList[1];
                    }
                    if (orderData.pro_come_at !== null || orderData.pro_come_at !== '') {
                        var proComeAtList = orderData.pro_come_at.split(" ");
                        arrivalDate = proComeAtList[0];
                        arrivalTime = proComeAtList[1];
                    }
                    if (orderData.fixed_at !== null || orderData.fixed_at !== '') {
                        var fixedAtList = orderData.fixed_at.split(" ");
                        faultRepairDate = fixedAtList[0];
                        faultRepairTime = fixedAtList[1];
                    }
                    var ccListStr='';
                    var ccList =[];
                    for (var j=0;j<orderData.ccList.length;j++) {
                        if (j < orderData.ccList.length-1 ) {
                            ccListStr += orderData.ccList[j].name+'(****'+orderData.ccList[j].mobile.substr(7,11)+'),'+'<br/>';
                            ccList.push(orderData.ccList[j].uuid);
                            console.log('have ,,,')
                        } else {
                            ccListStr += orderData.ccList[j].name+'(****'+orderData.ccList[j].mobile.substr(7,11)+')';
                            ccList.push(orderData.ccList[j].uuid);
                            console.log(' no  have ,,,')
                        }
                    }

                    if (orderData.machineName === null) {
                        orderData.machineName = '';
                    }

                    if (orderData.typeNm === null) {
                        orderData.typeNm = '';
                    }

                    this.repairData = [
                        {clickType: 'repair',title: '报修人',content: orderData.userName,type: 'entry',showRightTpye: '',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                        {clickType: 'inst',title: '报修机构',content: orderData.instName,type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                        {clickType: 'phone',title: '联系电话',content: orderData.userMobile,type: 'text',showRightTpye: 'arrow',showType: 'divide',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                        {clickType: 'urgent',title: '紧急程度',content: orderData.urgentLevelName,type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: orderData.urgentLevel,ccList:[]},
                        {clickType: 'fault',title: '故障类型',content: orderData.faultType,type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: orderData.faultTypeUuid,emergencyTypeUuid: '',ccList:[]},
                        {clickType: 'deviceCode',title: '设备编码',content: orderData.machineCode,type: 'entry',showRightTpye: 'scan',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                        {clickType: 'device',title: '报修设备',content: orderData.machineName+orderData.typeNm,type: 'text',showRightTpye: '',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                        {clickType: 'faultDes',title: '故障描述',content: orderData.describe,type: 'textarea',showRightTpye: '',showType: 'image',images: list,equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                        {clickType: 'repairDate',title: '报修日期',content: repairDate,type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                        {clickType: 'repairTime',title: '报修时间',content: repairTime,type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                        {clickType: 'copyFor',title: '抄送给',content: ccListStr,type: 'textarea',showRightTpye: 'arrow',showType: 'content',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:ccList},
                        {clickType: 'company',title: '维修单位',content: orderData.service_name,type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                        {clickType: 'repairPeople',title: '维修人员',content: orderData.pro_name,type: 'entry',showRightTpye: '',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                        {clickType: 'arrivalDate',title: '维修人员到达日期',content: arrivalDate,type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                        {clickType: 'arrivalTime',title: '维修人员到达时间',content: arrivalTime,type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                        {clickType: 'faultRepairDate',title: '故障修复日期',content: faultRepairDate,type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                        {clickType: 'faultRepairTime',title: '故障修复时间',content: faultRepairTime,type: 'text',showRightTpye: 'arrow',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                        {clickType: 'remark',title: '备注',content: orderData.remark,type: 'entry',showRightTpye: '',showType: '',images: [],equipUuid: '',provider_uuid: '',faultTypeUuid: '',emergencyTypeUuid: '',ccList:[]},
                    ];
                } else {

                }
            },
            async deviceCodeHandler(payload) {
                var type = payload.clickType;
                var code = payload.code;

                if (type === 'repair') {
                    this.repairData[0].content = code;
                } else if (type === 'deviceCode') {
                    if (code === null || code === '') {

                    } else {
                        if (code.length>=16 && code.length<=20) {
                            this.machineCodeDetailsFunc(code);
                        }
                    }
                } else if (type === 'repairPeople') {
                    this.repairData[12].content = code;
                } else if (type === 'remark') {
                    this.repairData[17].content = code;
                }
            },
            async machineCodeDetailsFunc(code) {
                var response = await machineCodeDetails(
                    JSON.parse(localStorage.getItem(userInfoData)).mobile,
                    code
                );
                if (response.data.code === 200) {
                    var status = response.data.data.status;
                    if (status === '1') {
                        this.$dialog.toast({
                            mes: "设备已删除",
                            timeout: 1500
                        });
                    } else if (status === '2') {
                        this.$dialog.toast({
                            mes: "设备已报废",
                            timeout: 1500
                        });
                    }
                    var isBlank = response.data.data.isBlank;
                    if (isBlank === '1') {
                        if (response.data.data.partnerUuid === this.partnerUuid) {
                            this.repairData[5].content = response.data.data.equipCode;
                            this.repairData[5].equipUuid = response.data.data.equipUuid;
                            this.repairData[6].content = response.data.data.name;
                            this.isSamePartnerUuid = true;
                        } else {
                            this.isSamePartnerUuid = false;
                            this.$dialog.toast({
                                mes: "不属于本机构的设备！",
                                timeout: 1500
                            });
                            return;
                        }
                    } else {
                        this.$dialog.toast({
                            mes: "设备已报废",
                            timeout: 1500
                        });
                    }
                } else {
                    this.$dialog.toast({
                        mes: response.data.msg,
                        timeout: 1500
                    });
                }
            },
            async machineUuidDetailsFunc(uuid) {
                var response = await machineUuidDetails(
                    JSON.parse(localStorage.getItem(userInfoData)).mobile,
                    uuid
                );
                if (response.data.code === 200) {
                    var equipDetailBean = response.data.data;
                    if (equipDetailBean.status === '1') {
                        this.$dialog.toast({
                            mes: "该设备已删除！",
                            timeout: 1500
                        });
                    } else if (equipDetailBean.status === '0') {
                        if (equipDetailBean.partnerUuid === this.partnerUuid) {
                            if (equipDetailBean.isBlank === '0') {
                                this.$dialog.toast({
                                    mes: "设备为空！",
                                    timeout: 1500
                                });
                                return;
                            } else if (equipDetailBean.isBlank === '1') {
                                this.repairData[5].content = equipDetailBean.equipCode;
                                this.repairData[5].equipUuid = equipDetailBean.equipUuid;
                                this.repairData[6].content = equipDetailBean.name;
                            }
                        } else {
                            this.$dialog.toast({
                                mes: "不属于本机构的设备！",
                                timeout: 1500
                            });
                            return;
                        }
                    }
                } else {
                    this.$dialog.toast({
                        mes: response.data.msg,
                        timeout: 1500
                    });
                }
            },
            revealHandleClick(type) {
                if (this.isEditState === '1' || this.isEditState === '2') {
                    this.isEnableEdit = true;
                    console.log(type);
                    if (type === 'inst') {
                        //报修机构
                        //离开当前页面之前先保存起来
                        localStorage.setItem(repairOrderSavedInstance,JSON.stringify(this.repairData));
                        this.$router.push({name: 'instList',params: {type:'repairOrder'}});
                    } else if (type === 'phone') {
                        //联系人电话
                    } else if (type === 'urgent') {
                        //紧急程度
                        this.isUrgentSheet = true;
                    } else if (type === 'fault') {
                        //故障类型
                        this.isFaultSheet = true;
                    } else if (type === 'faultDes') {
                        //故障描述
                        //离开当前页面之前先保存起来
                        localStorage.setItem(repairOrderSavedInstance,JSON.stringify(this.repairData));
                        localStorage.setItem(isEditRepairOrder,this.isEditState);
                        this.$router.push({name: 'repairFaultDescription'})
                    } else if (type === 'repairDate') {
                        let that = this;
                        //报修日期
                        var nowData = util.getNowDate();
                        var pastData = util.getPastTwoMonths();
                        this.initDatePickerFunc(type,nowData,pastData);
                    } else if (type === 'repairTime') {
                        //报修时间
                        this.initTimePickerFunc(type);
                    } else if (type === 'company') {
                        //维修单位
                        //离开当前页面之前先保存起来
                        localStorage.setItem(repairOrderSavedInstance,JSON.stringify(this.repairData));
                        this.$router.push({name: 'serviceProvider'});
                    } else if (type === 'arrivalDate') {
                        //报修人员到达日期
                        var nowData = util.getNowDate();
                        var pastData = util.getPastTwoMonths();
                        this.initDatePickerFunc(type,nowData,pastData);
                    } else if (type === 'arrivalTime') {
                        //维修人员到达时间
                        this.initTimePickerFunc(type);
                    } else if (type === 'faultRepairDate') {
                        //故障修复日期
                        var nowData = util.getNowDate();
                        var pastData = util.getPastTwoMonths();
                        this.initDatePickerFunc(type,nowData,pastData);
                    } else if (type === 'faultRepairTime') {
                        //故障修复时间
                        this.initTimePickerFunc(type);
                    } else if (type === 'copyFor') {
                        //抄送
                        if (this.isEditState === '1') {
                            //离开当前页面之前先保存起来
                            localStorage.setItem(repairOrderSavedInstance,JSON.stringify(this.repairData));
                            localStorage.setItem(isEditRepairOrder,this.isEditState);
                            this.$router.push({name: 'repairCopySearch',params:{taskUUid: this.taskUUid}});
                        }
                    }
                } else {
                    this.isEnableEdit = false;
                }
            },
            initDatePickerFunc(type,nowData,pastData) {
                let that = this;
                var nowStr = nowData.nowYear + '-' + nowData.nowMonth + '-' + nowData.nowDay;
                var pastStr = pastData.pastYear + '-' + pastData.pastMonth + '-' + pastData.pastDay;
                weui.datePicker({
                    start: pastStr,
                    end: nowStr,
                    cron: '* * *',
                    defaultValue: [nowData.nowYear, nowData.nowMonth, nowData.nowDay],
                    onChange: function (result) {
                        console.log(result.label);
                        if (type === 'repairDate') {
                            that.repairData[8].content = result[0].value+'-'+result[1].value+'-'+result[2].value;
                        } else if (type === 'arrivalDate') {
                            that.repairData[13].content = result[0].value+'-'+result[1].value+'-'+result[2].value;
                        } else if (type === 'faultRepairDate') {
                            that.repairData[15].content = result[0].value+'-'+result[1].value+'-'+result[2].value;
                        }
                    },
                    onConfirm: function (result) {
                        console.log(result);
                    },
                    id: 'datePicker'
                });
            },
            initTimePickerFunc(type) {
                let that = this;
                var timeList = util.getTime();
                weui.picker(timeList, {
                    defaultValue: [0],
                    className: 'custom-classname',
                    onChange: function (result) {
                        console.log(result);
                        if (type === 'repairTime') {
                            that.repairData[9].content = result[0].label;
                        } else if (type === 'arrivalTime') {
                            that.repairData[14].content = result[0].label;
                        } else if (type === 'faultRepairTime') {
                            console.log(result[0].label);
                            that.repairData[16].content = result[0].label;
                            console.log(that.repairData[16].content);
                        }
                    },
                    onConfirm: function (result) {
                        console.log(result);
                    },
                    id: 'timePicker'
                });
            },
            scanHandleClick(type) {
                let that = this;
                // that.machineUuidDetailsFunc('57aeaa33b98345a8a39a1f74dee9c594');
                if (this.isEditState === '1' || this.isEditState === '2') {
                    if (type === 'scan') {
                        wx.scanQRCode({
                            needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
                            scanType: ["qrCode"], // "qrCode","barCode"可以指定扫二维码还是一维码，默认二者都有
                            success: function (res) {
                                var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
                                var obj = JSON.parse(result);
                                that.machineUuidDetailsFunc(obj.uuid);
                            }
                        });
                    }
                }
            },
            //编辑按钮
            editHandleClick() {
                this.isShowEdit = false;
                this.isShowSave = true;
                this.isEditState = '2';
                localStorage.setItem(isEditRepairOrder,this.isEditState);
            },
            //抄送按钮
            copyHandleClick() {
                //离开当前页面之前先保存起来
                localStorage.setItem(repairOrderSavedInstance,JSON.stringify(this.repairData));
                localStorage.setItem(isEditRepairOrder,this.isEditState);
                this.$router.push({name: 'repairCopySearch',params:{taskUUid: this.taskUUid}});
            },
            //归档按钮
            async archiveHandleClick() {
                this.$dialog.confirm({
                    title: '',
                    mes: '归档后信息不可以再修改',
                    opts: () => {
                        this.$dialog.loading.open('加载中...');
                        this.orderArchiveFunc();
                    }
                });
            },
            //保存按钮
            saveHandleClick() {

                if (this.repairData[7].content === '' && this.repairData[7].images.length <= 0) {
                    this.$dialog.toast({
                        mes: "请输入故障描述！",
                        timeout: 1500
                    });
                    return
                }

                this.repairDate = this.repairData[8].content;
                this.repairTime = this.repairData[9].content;
                this.arrivalDate = this.repairData[13].content;
                this.arrivalTime = this.repairData[14].content;
                this.faultRepairDate = this.repairData[15].content;
                this.faultRepairTime = this.repairData[16].content;

                if (this.arrivalDate === '' && this.arrivalTime !== '') {
                    this.$dialog.toast({
                        mes: "请输入维修任务到达日期！",
                        timeout: 1500
                    });
                    return
                }

                if (this.faultRepairDate === '' && this.faultRepairTime !== '') {
                    this.$dialog.toast({
                        mes: "请输入故障修复日期！",
                        timeout: 1500
                    });
                    return
                }

                if (this.repairTime === '') {
                    this.repairTime = '00:00';
                }

                if (this.arrivalDate !== '' && this.arrivalTime === '') {
                    this.arrivalTime = '00:00';
                }

                if (this.faultRepairDate !== '' && this.faultRepairTime === '') {
                    this.faultRepairTime = '00:00';
                }
                //报修
                var warningDay = this.repairDate + ' ' + this.repairTime;
                //故障修复
                var repairDay = this.faultRepairDate + ' ' + this.faultRepairTime;
                //运维人员到达
                var maintenanceDay = this.arrivalDate + ' ' + this.arrivalTime;
                //故障修复时间不得早于维修人员到达时间 (不得小于)
                if (repairDay !== ' ' && maintenanceDay !== ' ' && !util.compareTime(repairDay,maintenanceDay)) {
                    this.$dialog.toast({
                        mes: "故障修复时间不得早于维修人员到达时间！",
                        timeout: 1500
                    });
                    return
                }
                //维修人员到达时间不得早于报修时间 （不得小于）
                if (maintenanceDay !== ' ' && warningDay !== ' ' && !util.compareTime(maintenanceDay,warningDay)) {
                    this.$dialog.toast({
                        mes: "维修人员到达时间不得早于报修时间！",
                        timeout: 1500
                    });
                    return
                }

                this.$dialog.loading.open('发送中...');
                if (this.repairData[7].images.length > 0) {
                    this.repairOrderWXUploadImgFunc('updateByUser');
                } else {
                    this.launchApplyUpdateByUserFunc();
                }
                // this.isShowEdit = true;
                // this.isShowSave = false;
                // this.isEditState = '0';
            },
            //发送按钮
            sendHandleClick () {
                this.isSendRepairState = true;

                if (this.isSamePartnerUuid === false) {
                    this.$dialog.toast({
                        mes: "不属于本机构的设备,请修改！",
                        timeout: 1500
                    });
                    return
                }

                if ((this.repairData[7].content === '' || this.repairData[7].content === null || this.repairData[7].content === undefined)
                && this.repairData[7].images.length <= 0) {
                    this.$dialog.toast({
                        mes: "请描述故障！",
                        timeout: 1500
                    });
                    return
                }

                this.repairDate = this.repairData[8].content;
                this.repairTime = this.repairData[9].content;
                this.arrivalDate = this.repairData[13].content;
                this.arrivalTime = this.repairData[14].content;
                this.faultRepairDate = this.repairData[15].content;
                this.faultRepairTime = this.repairData[16].content;
                // console.log(this.repairDate);
                // console.log(this.repairTime);
                // console.log(this.arrivalDate);
                // console.log(this.arrivalTime);
                // console.log(this.faultRepairDate);
                // console.log(this.faultRepairTime);

                if (this.arrivalDate === '' && this.arrivalTime !== '') {
                    this.$dialog.toast({
                        mes: "请输入维修任务到达日期！",
                        timeout: 1500
                    });
                    return
                }

                if (this.faultRepairDate === '' && this.faultRepairTime !== '') {
                    this.$dialog.toast({
                        mes: "请输入故障修复日期！",
                        timeout: 1500
                    });
                    return
                }

                if (this.repairTime === '') {
                    this.repairTime = '00:00';
                }

                if (this.arrivalDate !== '' && this.arrivalTime === '') {
                    this.arrivalTime = '00:00';
                }

                if (this.faultRepairDate !== '' && this.faultRepairTime === '') {
                    this.faultRepairTime = '00:00';
                }
                //报修
                var warningDay = this.repairDate + ' ' + this.repairTime;
                //故障修复
                var repairDay = this.faultRepairDate + ' ' + this.faultRepairTime;
                //运维人员到达
                var maintenanceDay = this.arrivalDate + ' ' + this.arrivalTime;
                //故障修复时间不得早于维修人员到达时间 (不得小于)
                if (repairDay !== ' ' && maintenanceDay !== ' ' && !util.compareTime(repairDay,maintenanceDay)) {
                    this.$dialog.toast({
                        mes: "故障修复时间不得早于维修人员到达时间！",
                        timeout: 1500
                    });
                    return
                }
                //维修人员到达时间不得早于报修时间 （不得小于）
                if (maintenanceDay !== ' ' && warningDay !== ' ' && !util.compareTime(maintenanceDay,warningDay)) {
                    this.$dialog.toast({
                        mes: "维修人员到达时间不得早于报修时间！",
                        timeout: 1500
                    });
                    return
                }
                this.$dialog.loading.open('发送中...');
                if (this.repairData[7].images.length > 0) {
                    this.repairOrderWXUploadImgFunc('applyByUser');
                } else {
                    this.orderApplyByUserFunc();
                }

            },
            async orderArchiveFunc() {
                var response = await orderArchive(
                    JSON.parse(localStorage.getItem(userInfoData)).mobile,
                    this.taskUUid
                )
                if (response.data.code === 200) {
                    this.isEditState = '0';
                    this.$dialog.loading.close();
                    this.$dialog.toast({
                        mes: '已归档',
                        timeout: 1500
                    });
                    //录入维修单归档成功后，清理录入维修单相关的缓存
                    localStorage.removeItem(repairOrderSavedInstance);
                    localStorage.removeItem(repairOrderData);
                    localStorage.removeItem(isEditRepairOrder);
                    localStorage.removeItem(instObject);
                    localStorage.removeItem(providerObject);
                    this.$router.back();
                } else {
                    this.$dialog.loading.close();
                    this.$dialog.toast({
                        mes: response.data.msg,
                        timeout: 1500
                    });
                }
            },
            repairOrderWXUploadImgFunc(repairState) {
                let that = this;
                var imageObj = this.repairData[7].images[this.idx];
                if (imageObj.imageType === 'WeiXin') {

                    wx.uploadImage({
                        localId: this.repairData[7].images[this.idx].imageUrl.toString(),
                        isShowProgressTips: 0,
                        success: function(res) {
                            // 上传序号，上传一张 累计 +1
                            that.idx++;

                            //本地图片ID 还没全部获取完图片媒体ID
                            if (that.idx < that.repairData[7].images.length) {

                                //存储图片媒体ID，用，号分割
                                that.serverIds += res.serverId + ',';

                                //调用上传递归函数
                                that.repairOrderWXUploadImgFunc(repairState);
                            } else {
                                //存储图片媒体ID，用，号分割
                                that.serverIds += res.serverId;
                                //上传序号归零
                                that.idx=0;
                                that.uploadQiNiuImageFunc(repairState);
                            }
                        }
                    });

                } else if (imageObj.imageType === 'QiNiu'){

                    this.idx++;
                    //本地图片ID 还没全部获取完图片媒体ID
                    if (this.idx < this.repairData[7].images.length) {
                        //存储图片媒体ID，用，号分割
                        this.imageStr += this.repairData[7].images[this.idx] + ',';
                        //调用上传递归函数
                        this.repairOrderWXUploadImgFunc(repairState);
                    } else {
                        if (this.serverIds === '') {
                            //存储图片媒体ID，用，号分割
                            this.imageStr += this.repairData[7].images[this.idx];
                            if (repairState === 'applyByUser' ) {
                                this.orderApplyByUserFunc();
                            } else if (repairState === 'updateByUser'){
                                this.launchApplyUpdateByUserFunc();

                            }
                        } else {
                            //存储图片媒体ID，用，号分割
                            this.imageStr += this.repairData[7].images[this.idx] + ',';
                            this.uploadQiNiuImageFunc(repairState);
                        }
                        //上传序号归零
                        this.idx=0;
                    }

                }
            },
            async uploadQiNiuImageFunc(repairState) {
                var response = await uploadQiNiuImage(
                    JSON.parse(localStorage.getItem(userInfoData)).mobile,
                    this.serverIds,
                    localStorage.getItem(openId)
                );
                if (response.data.code === 200) {
                    this.imageStr = response.data.msg;
                    if (repairState === 'applyByUser' ) {
                        this.orderApplyByUserFunc();
                    } else if (repairState === 'updateByUser'){
                        this.launchApplyUpdateByUserFunc();

                    }
                    // this.$dialog.confirm({
                    //     title: '测试微信图片上传',
                    //     mes: response.data.msg,
                    //     opts: () => {
                    //         this.$dialog.toast({mes: '你点了确定', timeout: 1000});
                    //     }
                    // });
                } else {
                    this.$dialog.loading.close();
                    this.serverIds = '';
                    this.idx=0;
                    this.$dialog.toast({
                        mes: "上传图片失败，请重试！",
                        timeout: 1500
                    });
                }
            },
            async orderApplyByUserFunc() {
                console.log(this.repairData[10].ccList.toString());
                this.$dialog.loading.open('加载中...');
                var response = await orderApplyByUser(
                    JSON.parse(localStorage.getItem(userInfoData)).mobile,
                    this.repairData[12].content,
                    this.repairData[11].provider_uuid,
                    this.instUuid,
                    this.repairData[5].equipUuid,
                    this.repairData[4].faultTypeUuid,
                    this.repairData[3].emergencyTypeUuid,
                    this.repairData[7].content,
                    this.imageStr,
                    this.repairData[8].content,
                    this.repairData[13].content,
                    this.repairData[15].content,
                    this.repairData[9].content,
                    this.repairData[14].content,
                    this.repairData[16].content,
                    this.repairData[10].ccList.toString(),
                    this.repairData[17].content,
                );

                if (response.data.code === 200) {
                    this.$dialog.loading.close();
                    this.$dialog.toast({
                        mes: '录入成功',
                        timeout: 1500
                    });
                    //录入维修单成功后，清理录入维修单相关的缓存
                    localStorage.removeItem(repairOrderSavedInstance);
                    localStorage.removeItem(repairOrderData);
                    localStorage.removeItem(isEditRepairOrder);
                    localStorage.removeItem(instObject);
                    localStorage.removeItem(providerObject);
                    // this.$router.back();
                    this.taskUUid = response.data.data.uuid;
                    this.userUuid = '';
                    this.repairState = '14';
                    this.isEditState = '0';
                    localStorage.setItem(isEditRepairOrder,this.isEditState);
                    var repairOrderObj = {
                        uuid: this.taskUUid,
                        userUuid: this.userUuid,
                        state: '14',
                    };
                    localStorage.setItem(repairOrderData,JSON.stringify(repairOrderObj));
                    this.initRepairOperation();
                    this.orderContentByUserFunc();
                } else {
                    this.$dialog.loading.close();
                    this.$dialog.toast({
                        mes: response.data.msg,
                        timeout: 1500
                    });
                }
            },
            async launchApplyUpdateByUserFunc() {
                console.log(this.repairData[10].ccList.toString());
                this.$dialog.loading.open('加载中...');
                var response = await launchApplyUpdateByUser(
                    JSON.parse(localStorage.getItem(userInfoData)).mobile,
                    this.taskUUid,
                    this.repairData[12].content,
                    this.repairData[11].provider_uuid,
                    this.instUuid,
                    this.repairData[5].equipUuid,
                    this.repairData[4].faultTypeUuid,
                    this.repairData[3].emergencyTypeUuid,
                    this.repairData[7].content,
                    this.imageStr,
                    this.repairData[8].content,
                    this.repairData[13].content,
                    this.repairData[15].content,
                    this.repairData[9].content,
                    this.repairData[14].content,
                    this.repairData[16].content,
                    this.repairData[10].ccList.toString(),
                    this.repairData[17].content,
                );
                if (response.data.code === 200) {
                    this.$dialog.loading.close();
                    this.isShowEdit = true;
                    this.isShowSave = false;
                    this.isEditState = '0';

                    for(var i=0 ;i<this.popWinList.length;i++) {
                        if (this.popWinList[i].type === 'save') {
                            this.popWinList[i].type = 'edit';
                            this.popWinList[i].text = '编辑';
                        }
                    }

                    //录入维修单成功后，清理录入维修单相关的缓存
                    localStorage.removeItem(repairOrderSavedInstance);
                    localStorage.removeItem(repairOrderData);
                    localStorage.removeItem(isEditRepairOrder);
                    localStorage.removeItem(instObject);
                    localStorage.removeItem(providerObject);
                    this.$router.back();
                } else {
                    this.$dialog.loading.close();
                    this.$dialog.toast({
                        mes: response.data.msg,
                        timeout: 1500
                    });
                }
            },
            //初始化底部按钮操作
            initRepairOperation() {
                console.log(this.repairState);
                if (this.userUuid === '' || this.userUuid === null || this.userUuid === undefined) {
                } else {
                    // this.isShowCopy = true;
                    //自定义增加维修单状态：1000  抄送给
                    this.repairState = '1000';
                    this.popWinList=[{id: 0,type: 'copy',text:'抄送给'}]
                }
                //进行中
                if (this.repairState === "14") {
                    //不可以编辑模式
                    if (this.isEditState === '0') {
                        // this.isShowEdit = true;
                        // this.isShowSave = false;
                        this.isShowSend = false;
                        this.isShowArchive = true;
                        // this.isShowCopy = true;
                        var noneEditList = [
                            {id: 0,type: 'edit',text:'编辑'},
                            {id: 1,type: 'copy',text:'抄送给'}];
                        this.popWinList = [...this.popWinList,...noneEditList];
                    }
                    //编辑模式
                    else if (this.isEditState === '2') {
                        // this.isShowEdit = false;
                        // this.isShowSave = true;
                        this.isShowSend = false;
                        this.isShowArchive = true;
                        // this.isShowCopy = true;
                        var editList = [
                            {id: 0,type: 'save',text:'保存'},
                            {id: 1,type: 'copy',text:'抄送给'}
                        ];
                        this.popWinList = [...this.popWinList,...editList];
                    }
                }
                //已经完成
                else if (this.repairState === '99'){
                    this.isShowEdit = false;
                    this.isShowSave = false;
                    this.isShowSend = false;
                    this.isShowArchive = false;
                    this.isShowCopy = false;

                    this.popWinList = [];
                }
                //抄送
                else if (this.repairState === '1000'){
                    this.isShowEdit = false;
                    this.isShowSave = false;
                    this.isShowSend = false;
                    this.isShowArchive = false;
                    this.isShowCopy = false;

                    this.popWinList = [];
                } else {
                    this.isShowEdit = false;
                    this.isShowSave = false;
                    this.isShowSend = true;
                    this.isShowArchive = false;

                    this.popWinList = [];
                }
            },
        }
    }
</script>

<style lang="scss">
    .repair-order-part {
        width: 100%;

        .repair-navbar-part {
            z-index:200;
            position: fixed;
            height: 1rem;
            width: 100%;
            top: 0;
            left: 0;
        }

        .operation-logo-part {
            width: 0.4rem;
            height: 0.1rem;
            margin-right: 0.1rem;
        }

        .repair-main-part {

            .reveal-msg-component-part {
                border-bottom: 1px solid #fafafa;

                .image-component-part {
                    padding-left: 0.4rem;
                    padding-right: 0.4rem;
                    background-color: #ffffff;
                }

                .content-main-part {
                    /*background-color: #fafafa;*/
                    background: #fafafa;
                    display: flex;
                    width: 100%;
                    padding: 0.2rem;
                    height: 1rem;
                    text-align: left;
                    align-items: center;

                    .title-part {
                        font-size: 1.2em;
                        margin-left: 0.2rem;
                    }
                }

                .divide-part {
                    background-color: #fafafa;
                    width: 100%;
                    padding: 0.1rem;
                }

                .scan-logo-part {
                    color: #3cc8a8;
                    padding-right: 0.1rem;
                    width: 0.6rem;
                    height: 0.5rem;
                }

                .iconfont {
                    font-size: 0.4rem;
                }

            }

        }

        .repair-order-operation-part {
            padding-top: 0.3rem;
            padding-bottom: 0.3rem;
            display: flex;
            background: #fafafa;

            .horizontal-part {
                margin: 0 auto;
                width: 28%;
            }

            .weui-btn {
                display: flex;
                height: 0.6rem;
                align-items: center;
                justify-content: center;
                font-size: 1.2em;
            }
        }

    }


</style>